package com.home.base.util;

import java.time.LocalDateTime;
import java.util.Date;

/**
 * @author ：chenxf
 * @date ：Created in 2019/8/28 10:31
 * @description：
 * @modified By：
 * @version: $
 */
public class WsUtil {
    private static String  sdkVersion="1808061600";


    public  static String getData(String sid,String uid,String cid,Long timestamp,Long sendtime){
        String getUrl="http://dataaq.yy.com/d.gif?sed=c5c6cfe50423f5ae&te=1&rl=yycomscene&td=16777217&ip=null&sd=#SID&sbd=#CID&ud=null&ot=#SENDTIME&dr=30&wy=0.4517701572944406&rf=http%3A%2F%2Fwww.yy.com%2F98187265%2F981872";
                //"http://ylog.hiido.com/c.gif?act=webentchndo&sessid=3b011943d99befe9&type=1&rel=yycomscene&tempid=16777217&ip=null&sid=@SID&subsid=#CID&uid=null&time=#SENDTIME&dr=480&wyy=0.4517701572944406&ref=http%3";
                //"http://stat2.web.yy.com/c.gif?act=webyyhb&rel=yycomscene&uid=#UID&ver=1.33&ref=http%3A%2F%2Fwww.yy.com%2F98187265%2F98187265&source=0&tlt=16777217&vt=0&topmic=0&ip=14.17.106.16&time=#TIMESTAMP&wyy=3ecb8b89efd6486ca8c732a9dcb7066a&sid=#SID&sidsub=#CID&hiido_ui=0.6565207725408164&dr=2";
        getUrl=getUrl.replaceAll("#SID",sid)
                .replaceAll("#UID",uid)
                .replaceAll("#CID",cid)
                .replaceAll("#TIMESTAMP",timestamp.toString())
                .replaceAll("#SENDTIME",sendtime.toString());
        return getUrl;
    }

    public static String postData(String sid,String uid,String cid,Long timestamp,Long sendtime,String roomId){
        String t="{\"sid\":#SID,\"uid\":#UID,\"appid\":0,\"cid\":#CID,\"sequence\":#TIMESTAMP,\"client_attribute\":{\"business\":\"\",\"client_type\":1,\"os\":\"ie\",\"model\":\"\",\"client\":\"web\",\"scale\":\"\",\"graphics_card\":\"\",\"osversion\":\"10\",\"vsdk_version\":\"\",\"hight\":\"696\",\"app_identify\":\"2\",\"app_version\":\"\",\"width\":\"780\",\"cpu\":\"\"},\"businessid\":0,\"avp_parameter\":{\"trans_version\":0,\"client_appid\":0,\"line_seq\":-1,\"ip\":0,\"room_id\":#ROOMID,\"service_type\":0,\"version\":0,\"gear\":4,\"send_time\":#SENDTIME,\"imsi\":0,\"client_type\":1,\"uid\":#UID,\"sdk_version\":#SDK}}";
        t=t.replaceAll("#SID",sid)
                .replaceAll("#UID",uid)
                .replaceAll("#CID",cid)
                .replaceAll("#TIMESTAMP",timestamp.toString())
                .replaceAll("#ROOMID",roomId)
                .replaceAll("#SENDTIME",sendtime.toString())
                .replaceAll("#SDK",sdkVersion);
        return t;
    }

    public static void main(String[] args){
        Long time=System.currentTimeMillis();
        System.out.println(time);
        String postData=WsUtil.postData("98187265","3298582","98187265",time,time/1000,"98187265");
        System.out.println(postData);
        String getData=WsUtil.getData("98187265","3298582","98187265",time,time/1000);
        System.out.println(getData);
    }
}
